//
//  DiscountMoreSmallImageTableViewCell.m
//  AroundTheWorld
//
//  Created by dllo on 16/5/20.
//  Copyright © 2016年 IfelseGo an. All rights reserved.
//

#import "DiscountMoreSmallImageTableViewCell.h"
#import "DiscountMoreCollectionCell.h"
#import "DiscountMoreHot_areaPlaceModel.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation DiscountMoreSmallImageTableViewCell

//自定义初始化
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addView];
//        self.smallArray = [NSMutableArray array];
        
    }
    return self;
}

- (void)addView
{
    self.contentView.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff,0xCFCFCF);
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(85, 85);
    flowLayout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    UICollectionView *collectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:flowLayout];
    
    collectionV.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:collectionV];
    
    //成为代理人
    collectionV.delegate = self;
    collectionV.dataSource = self;
    self.myCollectionV = collectionV;
    //注册
    [self.myCollectionV registerClass:[DiscountMoreCollectionCell class] forCellWithReuseIdentifier:@"reuse"];


}
//cell数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}
//建cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    DiscountMoreCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    DiscountMoreHot_areaPlaceModel *model = [self.myPlaceArrayM objectAtIndex:indexPath.row];

    cell.textLabel.text = model.name;
    [cell.samllImageV sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@""]];
    
    return cell;
}

- (void)setMyPlaceArrayM:(NSMutableArray *)myPlaceArrayM
{
    _myPlaceArrayM = myPlaceArrayM;
    [self.myCollectionV reloadData];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.myCollectionV.frame = self.contentView.frame;
}

//点击触发方法

//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    SubjectModel *model = [self.subjectArray objectAtIndex:indexPath.row + 1];
//    self.myBlock(model.url, model.title);
//}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
